﻿@model Coevery.Fields.Fields.BooleanField
@using Orchard.Utility.Extensions;
@using Coevery.Fields.Settings;
@{
    var settings = Model.PartFieldDefinition.Settings.GetModel<BooleanFieldSettings>();
    var settingname = Model.PartFieldDefinition.Name;
    var classString = settings.DependencyMode == DependentType.Control ? "control controls controlField" : "control controls";
}

<label class="title control-label" for="@Html.FieldIdFor(m => m.Value)">@Model.DisplayName</label>
<div class="@classString errortips" data-name ="@settingname">
    @switch (settings.SelectionMode) {
        case BooleanDisplayMode.Checkbox:
            <label class="checkbox" for="@(Html.FieldIdFor(m => m.Value))" >
            <input type="checkbox" id="@(Html.FieldIdFor(m => m.Value))" value="true" name="@Html.FieldNameFor(m => m.Value)" @if (Model.Value.HasValue && Model.Value.Value) { <text>checked</text> } 
                @if (!string.IsNullOrWhiteSpace(settings.HelpText)){<text>helper:text='@settings.HelpText'</text> }
                />
                <input name="@Html.FieldNameFor(m => m.Value)" type="hidden" value="false" />
            </label>
                                                                                                                              break;
        case BooleanDisplayMode.Radiobutton:
            <div class="clearfix">
                <label for="radio-true" class="radio span4">
            <input type="radio" name="@Html.FieldNameFor(m => m.Value)" id="radio-true" value="true" @if (Model.Value.HasValue && Model.Value.Value) { <text>checked</text> } 
                @if (!string.IsNullOrWhiteSpace(settings.HelpText)){<text>helper:text='@settings.HelpText'</text> }
                />
                    @T("True")
                </label>
                <label for="radio-false" class="radio span4">
            <input type="radio" name="@Html.FieldNameFor(m => m.Value)" id="radio-false" value="false" @if (Model.Value.HasValue && !Model.Value.Value) { <text>checked="checked"</text> } />
                    @T("False")
                </label>
            </div>
                                                                                                       break;
    }
    @Html.ValidationMessageFor(m => m.Value)
</div>
